package com.lcf.trans.error;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
@Slf4j
public class ErrorHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Map<String, Object> resultMap(Exception ex) {
        Map<String, Object> resultMap = new HashMap<>();

        ex.printStackTrace();
        resultMap.put("errCode", 500);
        resultMap.put("errMsg", ex.getMessage());//指挥打印错误原因，没有详情
        return resultMap;

    }
}
